package cn.itlaobing.web.service;

import java.io.IOException;
import java.sql.SQLException;
import java.util.Date;

import cn.itlaobing.web.dao.UserDao;
import cn.itlaobing.web.exception.MyeEXception;
import cn.itlaobing.web.model.UserModel;

public class UserService {
	private UserDao ud=new UserDao();
	public UserModel queryOne(String query,String pwd) throws MyeEXception{
		UserModel um;
		try {
			um=ud.QueryOne(query,pwd);
		} catch (SQLException e) {
			e.printStackTrace();
			throw new MyeEXception(e.getMessage());
		} catch (IOException e) {
			e.printStackTrace();
			throw new MyeEXception(e.getMessage());
		}finally {
			try {
				ud.close();
			} catch (SQLException e) {
				e.printStackTrace();
				throw new MyeEXception(e.getMessage());
			}
		}
		return um;
	}
	public int updateTime(Date nowTime,Integer id) throws MyeEXception{
		int row=0;
		try {
			row=ud.updateTime(nowTime, id);
		} catch (SQLException e) {
			e.printStackTrace();
			throw new MyeEXception(e.getMessage());
		} catch (IOException e) {
			e.printStackTrace();
			throw new MyeEXception(e.getMessage());
		}finally{
			try {
				ud.close();
			} catch (SQLException e) {
				e.printStackTrace();
				throw new MyeEXception(e.getMessage());
			}
		}
		return row;
	}
}
